package com.zhyt.intelligentpipeline.vo;


import com.zhyt.intelligentpipeline.model.ResidualStrength;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResidualStrengthResult {

    /*失效压力**/
    private double failurePressure;

    /*安全工作压力**/
    private double safeWorkingPressure;

    private String comment;

    public static ResidualStrengthResult getInstance(ResidualStrength residualStrength){
        ResidualStrengthResult residualStrengthResult = new ResidualStrengthResult();
        double safeWorkingPressure = ResidualStrength.getSafeWorkingPressure(residualStrength);
        residualStrengthResult.setSafeWorkingPressure(safeWorkingPressure);
        double failurePressure = ResidualStrength.getFailurePressure(residualStrength);
        residualStrengthResult.setFailurePressure(failurePressure);
        //设计压力
        double designPressure = residualStrength.getDesignPressure();
        double level_value = safeWorkingPressure / designPressure;
        if(level_value > 1){
            residualStrengthResult.setComment(WorkingTypeConst.LEVEL1_CORRODE);
        }
        if((residualStrength.getUsingCoefficients() < level_value) && (level_value <= 1)){
            residualStrengthResult.setComment(WorkingTypeConst.LEVEL2_CORRODE);
        }
        if(level_value < residualStrength.getUsingCoefficients()){
            residualStrengthResult.setComment(WorkingTypeConst.LEVEL3_CORRODE);
        }
        double result_value = residualStrength.getCorrosionDefectDepth() / residualStrength.getPipeNominalWallThickness();
        if(result_value >= 0.8){
            residualStrengthResult.setComment(WorkingTypeConst.LEVEL3_CORRODE);
        }
        return residualStrengthResult;
    }


}
